package com.kerpow.KSheet;

import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

public class StatView extends LinearLayout {

	public StatView(Context context, AttributeSet attrs) {
		super(context, attrs);
		TextView t;
		
		String label = attrs.getAttributeValue("http://schemas.android.com/apk/res/com.kerpow.KSheet", "label");
		String value = attrs.getAttributeValue("http://schemas.android.com/apk/res/com.kerpow.KSheet", "value");
		
		LayoutParams lp;
		
		
		t = new TextView(context);
		t.setText(label);
		t.setTextAppearance(context, R.style.Label);
		lp = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,  ViewGroup.LayoutParams.WRAP_CONTENT, 1);
		t.setLayoutParams(lp);
		t.setPadding(0, 0, 0, 0);
		//t.setBackgroundColor(Color.GRAY);
		this.addView(t);
		
		t = new TextView(context);
		t.setText(value);
		t.setPadding(5, 0, 0, 0);
		t.setGravity(Gravity.RIGHT);
		
		t.setTextAppearance(context, R.style.Value);
		lp = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,  ViewGroup.LayoutParams.WRAP_CONTENT, 0);
		t.setLayoutParams(lp);
		//t.setBackgroundColor(Color.LTGRAY);
		this.addView(t);
		
		this.setOrientation(LinearLayout.HORIZONTAL);
	}

	public StatView(Context context) {
		super(context);
	}
	
	public void setValue(String value){
		TextView t = (TextView) this.getChildAt(1);
		t.setText(value);
	}




}
